home *** CD-ROM | disk | FTP | other *** search
- /**
- * Scout - The Amiga System Monitor
- *
- *------------------------------------------------------------------
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * You must not use this source code to gain profit of any kind!
- *
- *------------------------------------------------------------------
- *
- * @author Andreas Gelhausen
- * @author Richard Körber <rkoerber@gmx.de>
- */
-
- #include "system_headers.h"
-
- static char initialdrawer[TEXT_LENGTH];
- static char initialfile[FILENAME_LENGTH] = "prt:";
- static char printfilename[FILENAME_LENGTH] = "prt:";
-
- ULONG MyRequest( UBYTE *gadgets,
- UBYTE *fmt, ... )
- {
- ULONG result = 0;
- UBYTE *buf;
-
- if (buf = tbAllocVecPooled(globalPool, TMP_STRING_LENGTH)) {
- va_list args;
- struct EasyStruct myreqES;
- struct Window *myreq_window;
-
- va_start(args,fmt);
- _vsnprintf(buf, TMP_STRING_LENGTH, fmt, args);
- va_end(args);
-
- get (WI_Main, MUIA_Window_Window, &myreq_window);
-
- myreqES.es_StructSize = sizeof(struct EasyStruct);
- myreqES.es_Flags = 0;
- myreqES.es_Title = "Scout Request";
- myreqES.es_TextFormat = buf;
- myreqES.es_GadgetFormat = gadgets;
- result = EasyRequest (myreq_window, &myreqES, NULL);
-
- tbFreeVecPooled(globalPool, buf);
- }
-
- return result;
- }
-
- static BOOL FileRequest (void) {
- struct Window *aslfr_window = NULL;
- struct FileRequester *requester;
- BOOL result = FALSE;
-
- get (WI_Main, MUIA_Window_Window, &aslfr_window);
-
- if (aslfr_window) {
- if (requester = AllocAslRequestTags (ASL_FileRequest,
- ASLFR_Window, aslfr_window,
- ASLFR_PrivateIDCMP, TRUE,
- ASLFR_SleepWindow, TRUE,
- NULL)) {
-
- result = AslRequestTags (requester,
- ASLFR_TitleText, "Choose file or printer!",
- ASLFR_InitialDrawer, initialdrawer,
- ASLFR_InitialFile, initialfile,
- ASLFR_DoSaveMode, TRUE,
- NULL);
-
- stccpy(initialdrawer, requester->fr_Drawer, sizeof(initialdrawer));
- stccpy(initialfile, requester->fr_File, sizeof(initialfile));
-
- stccpy(printfilename, initialdrawer, sizeof(printfilename));
- AddPart(printfilename, initialfile, sizeof(printfilename));
-
- FreeAslRequest (requester);
- }
- }
- return (result);
- }
-
- BPTR PrintHandle;
- LONG PrintHandleMode = MODE_NEWFILE;
-
- BPTR HandlePrintStart (char *filename) {
- PrintHandle = (BPTR)NULL;
-
- if (AP_Scout) {
- if ((! filename) && (! FileRequest()))
- return ((BPTR)NULL);
- ApplicationSleep(TRUE);
- } else if ((! filename) || (filename[0] == '\0')) {
- return (Output());
- }
- if (filename) {
- stccpy(printfilename, filename, sizeof(printfilename));
- }
- if (! (PrintHandle = Open (printfilename, PrintHandleMode))) {
- if (PrintHandleMode == MODE_OLDFILE) {
- PrintHandle = Open (printfilename, MODE_NEWFILE);
- }
- if (! PrintHandle)
- MyRequest ("Continue", "Couldn't open file \'%s\'!", printfilename);
- }
- if (PrintHandle) {
- Seek (PrintHandle, 0, OFFSET_END);
- }
- return (PrintHandle);
- }
-
- void HandlePrintStop (void) {
- if (AP_Scout) {
- ApplicationSleep(FALSE);
- }
- if (PrintHandle) {
- Close (PrintHandle);
- }
- }
-
-
-